{%include file="index.header.tpl.php"%}
{%include file="index.left.tpl.php"%}
  <!--主要内容开始-->
<div class="content-wrapper">
    <section class="content">
        <div class="row">
            <form action="" method="get">
            <section class="col-lg-3 connectedSortable" style="padding-right:0px;">
                <div class="box box-solid">
                    <div class="box-header with-border" id="boring">
                        <div class="form-group">
                            <div class="input-group col-sm-12 col-xs-12">
                                <select class="form-control" name="grade_id" id="grade_id">
                                    <option value="">请选择年级</option>
                                    {%foreach from=$grade_lists key=key item=value%}
                                    <option value="{%$value.grade_id%}">{%$value.grade_name%}</option>
                                    {%/foreach%}
                                </select>
                            </div>
                        </div>
                        
								<!--	<div class="form-group">
										<select class="form-control classfy" style="padding:0;" id="number2">
											  <option>请选择班级类别</option>
											  <option>文科</option>
											  <option>理科</option>
										</select>					  
								</div>-->
                        <div class="form-group class" style="height:100px; overflow-y:scroll;" id="number3">
                            <p>请先选择年级再选择班级</p>
                        </div>
                        <!--<button type="submit" class="form-control btn btn-default btn-xs">确 定</button>-->
                    </div>
                </div><!--box box-solid-->
                <div class="box box-solid">
                    <div class="box-header with-border">
                        <label>考试名称</label>
                        <div class="form-group">
                            <select id="sem_id" name="semester_id" class="form-control" style="padding:0;">
                                <option>请选择学年学期</option>
                                {%foreach from=$semester_lists key=key item=value%}
                                <option value="{%$value.semester_id%}">{%$value.semester_name%}</option>
                                {%/foreach%}
                            </select>
                        </div>
                        <div class="form-group">
                            <select name="exam_id" id="number33" class="form-control" style="padding:0;">
                                <option>请先选择学期</option>
                            </select>
                        </div>
                    </div>
                </div><!--box box-solid-->
                <div class="box box-solid">
                    <div class="box-header with-border">
                        <label>学生类型</label>
                        <div class="form-group">
                            <select name="student_type" class="form-control" style="padding:0;">
                                <option value="0">全部</option>
                                <option value="1">全部不含借读生</option>
                                <option value="2">全部不含转入生</option>
                                <option value="3">只计借读生</option>
                                <option value="4">只计转入生</option>
                            </select>
                        </div>
                    </div>
                </div><!--box box-solid-->
                <div class="box box-solid">
                    <div class="box-header with-border">
                        <label>科目选择</label>
                        <div class="form-group" style="padding-left:10px; height:120px; overflow-y:scroll; margin-bottom:30px;">
                            <label><input type="radio" name="subject_id" value="all"> 总分</label><br/>
                            {%foreach from=$subject_lists key=key item=value%}
                            <label><input type="radio" name="subject_id" value="{%$value.subject_id%}">{%$value.subject_name%}</label><br/>
                            {%/foreach%}
                        </div>
                        <input type="hidden" name="a" value="score.data">
                        <button type="submit" class="btn btn-primary btn-sm">统 计</button>
                        <a href="" class="btn btn-warning btn-sm">导 出</a>

                    </div>
                </div><!--box box-solid-->
            </section>
            </form>
            <section class="col-lg-9 connectedSortable">
                <div class="box box-default box-solid">

                        <div class="box-header with-border">
                            <span class="fa fa-exchange" style="float:left; font-size:18px; padding-top:3px; color:#3c8dbc;" ></span>
                            <p class="box-title">成绩分析</p>
                        </div>
                        <div class="box-body">
                            <h4 class="text-center">{%$subject_name%}{%$grade_name%}综合分析</h4>
                            <div style="width:100%; overflow-x:scroll;">
                                <table class="table table-bordered table-striped" id="mytable">
                                    <thead>
                                    <tr>
                                        <td>班级</td>
                                        <td>教师</td>
                                        <td>与考数</td>
                                        <td>实考数</td>
                                        {%foreach from=$r_level key=key item=value%}
                                        <td>{%$value.min%}~{%$value.max%}</td>
                                        {%/foreach%}
                                        <td>最高分</td>
                                        <td>最低分</td>
                                        <td>平均分</td>
                                        <td>排名</td>
                                        {%foreach from=$r_section key=key item=value%}
                                        <td>{%$value.name%}率</td>
                                        {%/foreach%}
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {%foreach from=$class_lists key=key item=value%}
                                    <tr>
                                        <td>{%$value.class_name%}</td>
                                        <td>{%$value.teacher%}</td>
                                        <td>{%$value.all%}</td>
                                        <td>{%$value.count%}</td>
                                        {%foreach from=$value.level key=k item=v%}
                                        <td>{%$v%}</td>
                                        {%/foreach%}

                                        <td>{%$value.max%}</td>
                                        <td>{%$value.min%}</td>
                                        <td>{%$value.avg|string_format:"%.2f"%}</td>
                                        <td>{%$value.rank+1%}</td>
                                        {%if $value.count>0%}
                                        {%foreach from=$value.section key=k item=v%}
                                        <td>{%$k%}率:{%$v%}</td>
                                        {%/foreach%}
                                        {%else%}
                                        {%foreach from=$value.section key=k item=v%}
                                        <td></td>
                                        {%/foreach%}
                                        {%/if%}
                                    </tr>
                                    {%/foreach%}

                                    </tbody>
                                </table>
                                <p>注意：{%foreach from=$r_section key=k item=v%}
                                            {%$v.name%}分数段：{%$v.min%}-{%$v.max%}
                                    {%/foreach%}
                                </p>
                                <table class="table table-bordered table-striped" id="mytable">
                                    <thead>
                                    <tr>
                                        <td>班级</td>
                                        <td>最高分</td>
                                        <td>最低分</td>
                                        <td>不及格</td>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {%foreach from=$class_lists2 item=value%}
                                    <tr>
                                        <td>{%$value.class_name%}</td>
                                        <td>{%foreach from=$value.max item=v%}{%$v.student_name%},{%/foreach%}</td>
                                        <td>{%foreach from=$value.min item=v%}{%$v.student_name%},{%/foreach%}</td>
                                        <td>{%foreach from=$value.bad item=v%}{%$v.student_name%},{%/foreach%}
                                        </td>
                                    </tr>
                                    {%/foreach%}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="box-footer text-center">
                            <div id="chartContainer1" style="height:460px; width:80%;"></div>
                        </div>
                        <!--<div class="box-footer text-center">
                            <div id="chartContainer" style="height:460px; width:80%;"></div>
                        </div>
						-->
                    
                </div><!--box box-default box-solid-->
            </section>
        </div><!--row-->
    </section>
</div>
  <!--主要内容结束-->
{%include file="index.footer.tpl.php"%}
<script type="text/javascript">
    $(document).ready(function () {
        $("#grade_id").change(function () {
            if ($(this).val() == "-1") {
                $("#industr").remove(); return;
            }
            else {
                var timestamp = new Date().getTime();
                $.ajax({
                    url:"index.php?a=student.gradelistjson",
                    type:"get",
                    data: "grade_id=" + $("#grade_id").find("option:selected").val() + "&timestamp=" + timestamp,
                    dataType:"json",
                    success:function(msg){
//                        <label><input type="checkbox" name="allChecked" id="allChecked" onclick="DoCheck()"> 全选 </label><br/>
//                            <label><input type="checkbox" name="nian[]"> 初一2班（文科班） </label><br/>
                        //实例2个字符串变量来拼接下拉列表
                        var industr = "";
                        //使用jquery解析json中的数据
                        $.each(msg, function (n, value) {
                            industr += ("<label><input type='checkbox' name='nian[]' value=\"" + value.class_id + "\">" + value.class_name);
                            industr += ("</label><br/>");
                        });
                        var top = "<label><input type='checkbox' name='allChecked' id='allChecked' onclick='DoCheck()'> 全选 </label><br/>"
                        $("#number3").html(top+industr);
                    }
                });

            }

        });

    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#sem_id").change(function () {
            if ($(this).val() == "-1") {
                $("#industr2").remove(); return;
            }
            else {
                var timestamp = new Date().getTime();
                $.ajax({
                    url:"index.php?a=score.semjson",
                    type:"get",
                    data: "sem_id=" + $("#sem_id").find("option:selected").val() + "&timestamp=" + timestamp,
                    dataType:"json",
                    success:function(msg){

                        //实例2个字符串变量来拼接下拉列表
                        var industr = "";
                        //使用jquery解析json中的数据
                        $.each(msg, function (n, value) {
                            industr += ("<option value=\"" + value.exam_id + "\">" + value.exam_name);
                            industr += ("</option>");
                        });

                        $("#number33").html(industr);
                    }
                });

            }

        });

    });
</script>
<script type="text/javascript">
    $(document).ready(function () {

        $("#number1").change(function () {
            if ($(this).val() == "-1") {
                $("#industr").remove(); return;
            }
            else {
                var timestamp = new Date().getTime();
                $.ajax({
                    url:" ",
                    type:"get",
                    data: $("#number1").find("option:selected").val() + "&timestamp=" + timestamp,
                    dataType:"json",
                    success:function(msg){

                        //实例2个字符串变量来拼接下拉列表
                        var industr = "";
                        //使用jquery解析json中的数据
                        $.each(msg, function (n, value) {
                            industr += ("<option value=\"" + value.student_id + "\">" + value.student_id);
                            industr += ("</option>");
                        });

                        $("#number3").html(industr);
                    }
                });

            }

        });

    });
</script>
<script src="static/js/canvasjs.min.js"></script>
{%foreach from=$class_lists key=key item=value%}
<script type="text/javascript">
    window.onload = function () {
        var charts = new CanvasJS.Chart("chartContainer1", {
            title: {
                text: "年级及班级分数段柱形图",
                fontSize: 18,
            },
            data: [{
                type: "column",
                dataPoints: [
                    {%foreach from=$value.level key=k item=v name=foo%}
            { y: {% if $v%}{%$v%}{%else%}0{%/if%}, label: "{%$r_level[$smarty.foreach.foo.iteration].min%}-{%$r_level[$smarty.foreach.foo.iteration].max%}", indexLabel: "{% if $v%}{%$v%}{%else%}0{%/if%}" },
            {%/foreach%}
//                    { y: {%$value.count1%}, label: "150-135", indexLabel: "{% if $value.count1%}{%$value.count1%}{%else%}0{%/if%}" },
//                    { y: {%$value.count2%}, label: "135-110", indexLabel: "{% if $value.count2%}{%$value.count1%}{%else%}0{%/if%}"},
//                    { y: {%$value.count3%}, label: "110-90" , indexLabel: "{% if $value.count3%}{%$value.count1%}{%else%}0{%/if%}"},
//                    { y: {%$value.count4%}, label: "90-60" , indexLabel: "{% if $value.count4%}{%$value.count1%}{%else%}0{%/if%}"},
//                    { y: {%$value.count5%}, label: "60-0" , indexLabel: "{% if $value.count5%}{%$value.count1%}{%else%}0{%/if%}"},
                ]
            }]
        });
        charts.render();
    }
</script>
{%/foreach%}
<!--<script type="text/javascript">
    jQuery(window).load(function ($) {
        $script.ready(['CanvasJS'], function () {
            var chart = new CanvasJS.Chart("chartContainer",
                {
                    title: {
                        text: "2016-2017第二学期期中数学初一级数学综合分析",
                        fontSize: 18
                    },

                    data: [
                        {
                            type: "stackedColumn100",
                            name: "优率",
                            showInLegend: true,
                            dataPoints: [
                                { y: 40, label: "101" },
                                { y: 10, label: "102" },
                                { y: 72, label: "103" },
                                { y: 30, label: "104" },
                                { y: 21, label: "105" },
                                { y: 21, label: "106" }
                            ]
                        }, {
                            type: "stackedColumn100",
                            name: "良率",
                            showInLegend: true,
                            /*color: "green ",*/
                            dataPoints: [
                                { y: 20, label: "101" },
                                { y: 14, label: "102" },
                                { y: 40, label: "103" },
                                { y: 43, label: "104" },
                                { y: 13, label: "105" },
                                { y: 21, label: "106" }
                            ]
                        },{
                            type: "stackedColumn100",
                            name: "合格率",
                            showInLegend: true,
                            dataPoints: [
                                { y: 20, label: "101" },
                                { y: 10, label: "102" },
                                { y: 72, label: "103" },
                                { y: 30, label: "104" },
                                { y: 21, label: "105" },
                                { y: 13, label: "106" }
                            ]
                        }, {
                            type: "stackedColumn100",
                            name: "不及格率",
                            showInLegend: true,
                            dataPoints: [
                                { y: 20, label: "101" },
                                { y: 14, label: "102" },
                                { y: 40, label: "103" },
                                { y: 43, label: "104" },
                                { y: 11, label: "105" },
                                { y: 24, label: "106" }
                            ]
                        },
                    ]
                });

            chart.render();
        });
    });
</script>-->
<script>
    //checbox全选  
    function DoCheck()
    {
        var ch=document.getElementsByName("nian[]");
        if(document.getElementsByName("allChecked")[0].checked==true)
        {
            for(var i=0;i<ch.length;i++)
            {
                ch[i].checked=true;
            }
        }else{
            for(var i=0;i<ch.length;i++)
            {
                ch[i].checked=false;
            }
        }
    }
</script>